import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { CommonService } from '../../../services/common.service';

@Component({
    selector: 'app-tree-select',
    templateUrl: './index.component.html',
    styleUrls: ['./index.component.scss']
})
export class TreeSelectComponent implements OnInit {
    @Input() parentFormGroup?: FormGroup;
    @Input() type: string; //用于判断组件的类型：form为表单提交,search为搜索
    @Input() id: string; //接收外部的id
    @Output() idChange: EventEmitter<any> = new EventEmitter();

    @Input() tree: any;
    @Input() nzPlaceHolder: string = '请选择';
    @Input() expandCompanyKeys: Array<string> = []; //接收默认展开指定的公司树节点
    @Input()
    maxHeight = '200px';

    constructor(private _commonService: CommonService, private _changeDetectorRef: ChangeDetectorRef) {}

    ngOnInit() {
    }

    /**
     * 选择树下拉框被选中时
     */
    onSelectChange(companyId: string) {
        this.idChange.emit(companyId);
    }
}
